package com.funny1.registrypostprocessor;

import com.funny1.app.Eoo;
import com.funny1.app.Roo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.support.*;
import org.springframework.core.PriorityOrdered;
import org.springframework.stereotype.Component;

/**
 * @author fanxiao  2021/8/23
 * @since 1.0.0
 */
@Slf4j
public class Roo1BeanDefinitionRegistryPostProcessor implements BeanDefinitionRegistryPostProcessor, PriorityOrdered {


	@Override
	public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) throws BeansException {
		log.info("roo1 BeanDefinitionRegistryPostProcessor postProcessBeanDefinitionRegistry");
		BeanDefinitionBuilder beanDefinitionBuilder =
				BeanDefinitionBuilder.genericBeanDefinition(KooBeanDefinitionRegistryPostProcessor.class);
		registry.registerBeanDefinition("kooBeanDefinitionRegistryPostProcessor",beanDefinitionBuilder.getBeanDefinition());
	}

	@Override
	public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
		log.info("roo1 BeanDefinitionRegistryPostProcessor postProcessBeanFactory");
	}

	@Override
	public int getOrder() {
		return Integer.MAX_VALUE;
	}
}
